import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Description:
 * @Author hugh.sun
 * @Date 2021/11/27 15:09
 */
public class testpython {
    @Test void test1()
    {
        String[] arguments = new String[] {"python", "E:\\git_project\\Ai_New\\src\\main\\resources\\reco.py", "E:\\picture\\g.jpg"};
        try {
            Process process = Runtime.getRuntime().exec(arguments);
            BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line = null;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            int re = process.waitFor();
            System.out.println(re);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Test void test2(){
        String[] args1=new String[]{"python","E:\\pythontest\\a.py"};
        try {
            Process pr=Runtime.getRuntime().exec(args1);
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    pr.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            try {
                int i = pr.waitFor();
                System.out.println(i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
